package com.example.wechattakeaway.controller;

import com.example.wechattakeaway.entity.UserAddress;
import com.example.wechattakeaway.form.addressform.InsertAddressForm;
import com.example.wechattakeaway.form.addressform.UpdateAddressForm;
import com.example.wechattakeaway.service.AddressService;
import com.example.wechattakeaway.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(value = "地址管理界面",tags = {"用户收货地址管理"})
@RestController
@RequestMapping("/AddressController")
public class AddressController  {

    @Autowired
    AddressService addressService;

    @ApiOperation(value = "新增一个收货地址",notes = "微信端")
    @PostMapping("/InsertAddress")
    public ResultVO InsertAddress(InsertAddressForm insertAddressForm){
        log.info(insertAddressForm.getAcceptPhone());
        log.info(insertAddressForm.getLabel());
        return addressService.InsertAddress(insertAddressForm);
    }

    @ApiOperation(value = "更新一个用户地址",notes = "微信端")
    @PostMapping("/UpdateAddress")
    public ResultVO UpdateAddress(UpdateAddressForm updateAddressForm){
        return addressService.UpdateAddress(updateAddressForm);
    }

    @ApiOperation(value = "根据id删除一个收货地址",notes = "微信端")
    @PostMapping("/DeleteAddress")
    public ResultVO DeleteAddress(Integer addressId){
        return addressService.DeleteAddress(addressId);
    }

    @ApiOperation(value = "根据用户id查询一个收货地址",notes = "微信端")
    @PostMapping("/SelectAddressById")
    public ResultVO SelectAddressById(Integer useId){
        return addressService.SelectAddressById(useId);
    }

//    @ApiOperation(value = "根据一个用户id查询他所有的收货地址",notes = "微信端")
//    @PostMapping("/SelectAddressByUser")
//    public ResultVO SelectAddressByUser(Integer pageNum, Integer sysuserId){
//        return addressService.SelectAddressByUser(pageNum,sysuserId);
//    }

}
